package com.hutao.medical.service.print;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hutao.medical.common.util.Result;
import com.hutao.medical.mapper.print.RegisterdMailMapper;
import com.hutao.medical.pojo.RegisterdMail;
import com.hutao.medical.pojo.vo.MailPrintVo;
import com.hutao.medical.pojo.vo.PrintRecordVo;

@Transactional
@Service
public class RegisterMailService {
	private static final Logger log = LoggerFactory.getLogger(RegisterMailService.class);
	
	@Autowired
	private RegisterdMailMapper registerdMailMapper;
	
	public Result insertRegisterMail(RegisterdMail registerdMail) {
		Result result = null;
		try {
			registerdMailMapper.intsertRegisterMail(registerdMail);
			result = new Result(true, "添加病案邮寄成功!", null, 200);
		} catch (Exception e) {
			log.error("---添加病案邮寄失败  ----" + e.getMessage());
			result = new Result(false, "添加病案邮寄失败!", null, 500);
		}
		return result;
		
	}
	
	
	/**
	 * 查询打印详情信息
	 * @param printRecordVo
	 * @return
	 */
	@Transactional(readOnly=true)
	public Map<String,Object> getRegisterMailPage(MailPrintVo mailPrintVo){
		Map<String,Object> map = new HashMap<>();
		List<Map<String,Object>> mailList = registerdMailMapper.getRegisterMailPage(mailPrintVo);
		long mailCount = registerdMailMapper.getRegisterMailPageTotal(mailPrintVo);
		map.put("mailList", mailList);
		map.put("totalCount", mailCount);
		return map;
	}
	
	public int deleteById(Integer id) {
		return registerdMailMapper.deleteById(id);
	}
	
	public int updatePrintStatusById(Integer id, Integer printStatus) {
		return registerdMailMapper.updatePrintStatusById(id, printStatus);
	}
	

}
